# -*- coding: utf-8 -*-

# File Name： conv
# Description :
# Author : lirui
# create_date： 2022/6/3
# Change Activity:

from torch import nn

from ....common.design_pattern.register.register_factory import REGISTER_FACTORY

_registry_name = 'conv_layer'


def _build_registry():
    """
    build normal lay registry.

    """
    _register = REGISTER_FACTORY.create_registry(_registry_name)
    _register.add('Conv1d', value=nn.Conv1d)
    _register.add('Conv2d', value=nn.Conv2d)
    _register.add('Conv3d', value=nn.Conv3d)


_build_registry()  # build when module load.


def build_conv_layer(cfg=None, name=None):
    """
    build norm layer

    Args:
        name: module name
        cfg: must contain num_features;

    Returns:

    """
    return REGISTER_FACTORY.build_from_config(_registry_name, cfg, name)
